home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
lang
/
nrcobol_1e.lha
/
NRCOBOL1e
/
WB13
/
Extra
/
NRCOBOL.REXX
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-09-22
|
9KB
|
315 lines
/*
Macro Arexx per compilare il Programma Cobol
Se il file non è stato salvato verrà richiesto di farlo
*/
Options Results
Call AddLib('rexxsupport.library',0,-30,0)
Call AddLib('rexxtricks.library',0,-30,0)
Operazione = UPPER(Arg(1))
Ret = '0A'x
Port = 'COBOL'
Est.Sorgente = 'COB'
Est.Exe = 'INT'
Est.Lista = 'LST'
Est.Change = 'CNG'
Est.LastComp = 'RES'
Est.LastErr = 'ERR'
Msg.NoPort = 'La porta di comunicazione' Port 'Non esiste'
Msg.ErrNoSave = 'Il file deve essere salvato con un nome'
Msg.ErrEst = 'Il file deve avere estensione' Est.Sorgente
Msg.ErrNoLista = 'Il file listato non esiste'
Msg.ErrLista = 'L''opzione di creazione del file' || RET ||'listato deve essere attivata'
Msg.Comp = 'Compilazione del file'
Msg.Wait = '-- Attendere Prego --'
Msg.NoErr = 'Nessun errore'
Msg.NoNextErr = 'Nessun altro errore'
Msg.Exe = 'Eseguo il file'
Msg.Config = 'Configurazione: (S) Salva - (U) Usa - (C) Cancella'
Msg.ErrSaveCfg = 'Impossibile salvare le impostazioni'
Msg.Save = 'Vuoi che il file sorgente' Ret 'venga salvato automaticamente?'
Msg.Lista = 'Vuoi che il compilatore generi' Ret 'il listato del file che sta compilando'
Msg.Debug = 'Vuoi che il compilatore generi' Ret 'il file di debug'
NRCOBOL = 'Lavoro:Programmazione/Cobol/NrCobol'
RUNCOB = 'Lavoro:Programmazione/Cobol/RunCob'
Modifiche = 0
CED.RESTNAME = 21
CED.FILENAME = 19
CED.NUMCHANGES = 18
CED.CURSORLINE = 47
/* DEFAULT SETUP */
Cfg.Nome = 'Cobol.prefs'
Cfg.Salvataggio = 0
Cfg.Lista = 1
Cfg.Debug = 1
/* MAIN */
Call Carica_Configurazione
If Port ~= Left(ADDRESS(),Length(Port)) Then
Say Msg.NoPort
Nome.Sorgente = Ottieni_Nome_File(CED.RESTNAME)
If Nome.Sorgente = '' Then
Do
'Save As'
If RESULT = 0 Then
Do
'Okay1' Msg.ErrNoSave
CALL Uscita(0)
End
End
Else
Do
'Status' CED.NUMCHANGES
Modifiche = Result
If Cfg.Salvataggio = 1 & Modifiche ~= 0 Then
'Save'
End
Nome.Sorgente = Ottieni_Nome_File(CED.FILENAME)
if UPPER(SuffixPart(Nome.Sorgente)) ~= Est.Sorgente Then
Do
'Okay1' Msg.ErrEst
Call Uscita(0)
End
Nome.File = Strip(FilePart(MakeSuffix(Nome.Sorgente,'',R)),'T','.')
Nome.Change = Nome.File || Est.Change
Nome.LastComp = Nome.File || Est.LastComp
Nome.LastErr = Nome.File || Est.LastErr
Nome.Exe = MakeSuffix(Nome.Sorgente, Est.Exe,'R')
Nome.Lista = MakeSuffix(Nome.Sorgente, Est.Lista,'R')
SELECT
When Operazione = 'COMPILA' Then
CALL Compila
When Operazione = 'ESEGUI' Then
CALL Esegui
When Operazione = 'CONFIGURA' Then
CALL Configura
When Operazione = 'ERRORI' Then
CALL Errori
OtherWise
NOP
End
CALL Uscita(0)
/* END MAIN */
Compila: Procedure Expose NRCOBOL RUNCOBOL Nome. Msg. Cfg. Ret Modifiche
'DM' Msg.Comp Nome.Sorgente Msg.Wait
If Cfg.Lista = 1 Then Opzioni = '-L'
If Cfg.Debug = 1 Then Opzioni = Opzioni '-D'
Opzioni = Opzioni '>' 'T:' || Nome.File
CALL Compilazione(Nome.Sorgente, Opzioni)
Risultato = VisualizzaRisultati('T:' || Nome.File)
CALL SetEnv(Nome.LastComp, Risultato)
CALL SetEnv(Nome.LastErr, 4)
'DM'
Return Risultato
Esegui: Procedure Expose NRCOBOL RUNCOBOL Nome. Msg. Cfg. Ret Modifiche
Run = GetEnv(Nome.LastComp)
If Run = '' Then
Run = 1
ModifichePrecedenti = GetEnv(Nome.Change)
If ModifichePrecedenti = '' Then
ModifichePrecedenti = Modifiche
CALL SetEnv(Nome.Change, Modifiche)
If ~Newer(Nome.Sorgente, Nome.Exe) | Modifiche ~= ModifichePrecedenti | Run = 0 Then
Run = Compila()
If Run = 1 Then
Do
'DM' Msg.Exe Nome.Exe
CALL Esecuzione(Nome.Exe)
End
'Dm'
Return Run
Configura: Procedure Expose Ret Cfg. Msg.
'Okay2' Msg.Save; Salvataggio = Result
'Okay2' Msg.Lista; Lista = Result
'Okay2' Msg.Debug; Debug = Result
Impostazioni = Salvataggio Lista Debug
Continua = 1
Do While Continua = 1
'DM' Msg.Config
Tasto = -1
Do Until Tasto ~= -1
'LASTKEY'
Tasto = RESULT
End
Key = Word( Tasto, 1)
SELECT
When Key = 33 Then CALL Salva
When Key = 22 Then CALL Usa
When Key = 51 Then Continua = 0
OtherWise NOP
End
End
'DM'
Return
Errori: Procedure Expose Nome. Msg. Cfg. CED. RET
Res = GetEnv(Nome.LastComp)
LastLine = GetEnv(Nome.LastErr)
If LastLine = '' Then LastLine = 4
Select
When Cfg.Lista = 0 Then Messaggio = Msg.ErrLista
When Res = 1 Then Messaggio = Msg.NoErr
When ~Exists(Nome.Lista) Then Messaggio = Msg.ErrNoLista
OtherWise
Fine = 0
Do Until Fine = 1
Line = SearchPattern(Nome.Lista, 'LINE', LastLine, 'L', 'N')
If Line ~= -1 Then
Do
Parse Var Result Dummy 'Line' Numero Errore
If DataType(Numero,'N') & Dummy ='' Then
Do
Messaggio = 'Errore alla Linea:' Numero || Ret || 'Causa:' Errore
LL Numero
'Dm' Errore
SetEnv(Nome.LastErr, Line + 1)
Fine = 1
End
Else
LastLine = Line + 1
End
Else
Do
Messaggio = Msg.NoNextErr
Fine = 1
End
End
End
'Okay1' Messaggio
Return
Salva:
If ~Open(Handle,'ENVARC:' || Cfg.Nome,'W') Then
'Okay1' Msg.ErrSaveCfg
Else
Writeln(Handle, Impostazioni)
Usa:
CALL SetEnv(Cfg.Nome, Impostazioni)
Continua = 0
Return
Compilazione: Procedure Expose NRCOBOL
ADDRESS COMMAND NRCOBOL '"' || Arg(1) || '"' Arg(2)
Return
Esecuzione: Procedure Expose RUNCOB
ADDRESS COMMAND RUNCOB '"' || Arg(1) || '"'
Return
Ottieni_Nome_File: Procedure
'Status' ARG(1)
Return RESULT
Newer: Procedure
NomeFile1 = ARG(1)
NomeFile2 = ARG(2)
Parse Value Statef(NomeFile1) With . . . . GiorniFile1 Minuti CinquSec .
SecondiFile1 = ( Minuti * 60 ) + ( CinquSec / 50 )
If Exists(NomeFile2) Then
Do
Parse Value Statef(NomeFile2) With . . . . GiorniFile2 Minuti CinquSec .
SecondiFile2 = ( Minuti * 60 ) + ( CinquSec / 50 )
If GiorniFile1 <= GiorniFile2 & SecondiFile1 < SecondiFile2 Then
Return 1
End
Return 0
Carica_Configurazione: Procedure Expose Cfg.
Configurazione = GetEnv(Cfg.Nome)
If Configurazione ~= '' Then
Parse Var Configurazione Cfg.Salvataggio Cfg.Lista Cfg.Debug
Return
VisualizzaRisultati: PROCEDURE Expose RET
Ok = 1
TempFile = ARG(1)
Intestazione = 'NRCOBOL V1.0d - cHArRiOTt97-98(c)'
Pattern.0 = 5
Pattern.1 = 'IDENTIFICATION DIVISION'
Pattern.2 = 'ENVIRONMENT DIVISION'
Pattern.3 = 'DATA DIVISION'
Pattern.4 = 'PROCEDURE DIVISION'
Pattern.5 = 'Ending at'
Adj.1 = 27
Adj.2 = 28
Adj.3 = 34
Adj.4 = 29
Adj.5 = 0
LCurr = 1
Do Pat = 1 To Pattern.0
LPrec = SearchPattern(TempFile, Pattern.Pat, LCurr, 'L', 'N')
IF LPrec = -1 Then
Do
LCurr = -1
LPrec = 0
End
Else If Pat < Pattern.0 Then
LCurr = SearchPattern(TempFile, Pattern.Pat, LPrec + 1, 'L', 'N')
Else
LCurr = LPrec
If LCurr ~= -1 Then
Do
PARSE Var Result (Pattern.Pat) Risultato.Pat
Risultato.Pat = Traduci(Strip(Risultato.Pat,'B','. '))
End
Else
Do
LCurr = LPrec + 1
Risultato.Pat = 'omessa'
Ok = 0
End
End
Messaggio = Intestazione
Do Pat = 1 For Pattern.0
Messaggio = Messaggio || Copies(Ret,2) || Left(Pattern.Pat,Adj.pat,'.') || Risultato.Pat
End
'Okay1' Me